<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <!--Inicia la composicion de la pagina en la plantilla-->
    <ui:composition template="/resource/template/plantilla.xhtml">

        <!--Segmento que define el contenido del header-->
        <ui:define name="head">
            <h:head>
                <f:loadBundle basename="request.document.label_es" var="label" />
                <f:loadBundle basename="request.document.message_es" var="message" />
                <f:loadBundle basename="request.document.help_#{logged.loggedIdiom}"  var="help" />
                <script>
                    $(function() {
                        $("#form1\\:universidad").mousedown(function() {
                            $("#form1\\:facultad").val(0);

                        });
                    });
                    $(document).ready(function() {
                        $(".mostrar").fancybox({
                            type: 'ajax',
                            width: 370,
                            height: 360,
                            scrolling: 'auto'
                        });



                    });
                    function verificar(dato)
                    {
                        var agree = confirm(dato);
                        if (agree)
                            return true;
                        else
                            return false;
                    }
                </script>
            </h:head>
        </ui:define>

        <!--Segmento que define el contenido de la pagina-->
        <ui:define name="content">
            <h:body>
                <h:outputText value="#{message.m0}" class="label" rendered="#{!access.visit}"/>
                <h:form  enctype="multipart/form-data" rendered="#{access.visit}">
                    <p:growl id="messages" showDetail="true"/>  
                    <div class="field">
                        <h:outputText value="#{label.field1}" class="label"/>
                        <h:inputText id="detalle" class="textfield" value="#{request_document.detalle}" size="30" maxlength="200" />
                        <p:watermark for="detalle" value="#{label.field2}"/>
                        <h:outputText class="required" value="*"/>
                    </div>
                    <div class="field">
                        <p:fileUpload value="#{request_document.file}" widgetVar="..." mode="simple"  allowTypes="/(\.|\/)(pdf)$/" />
                        <h:outputText class="required" value="*"/>
                    </div>
                    <!--INSERTAR -->
                    <h:commandButton value="#{label.button1}" class="button" actionListener="#{request_document.insert}"  onclick="return verificar('#{message.m7}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                    <!--ACTUALIZAR -->
                    <h:commandButton value="#{label.button2}" class="button" actionListener="#{request_document.update}" rendered="#{access.update}" onclick="return verificar('#{message.m8}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>
                    <!--ELIMINAR -->
                    <h:commandButton value="#{label.button3}" class="button" actionListener="#{request_document.delete}" rendered="#{access.delete}" onclick="return verificar('#{message.m9}')"/>
                    <!--LIMPIAR -->
                    <h:commandButton value="#{label.button4}" class="button" actionListener="#{request_document.clear}"/>
                    <c:set var="list" value="#{request_documentFind.listByLoggedId}"/>
                    <h:panelGroup layout="block" class="tableWrapper" rendered="#{not empty list}">
                        <h:dataTable var="p" value="#{list}" class="dataTable">
                            <h:column>
                                <h:commandLink class="editButton" actionListener="#{request_document.selectedtempId(p.id)}"/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field0}</f:facet> 
                                <h:outputText value="#{p.id_solicitud} "/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field1}</f:facet> 
                                <h:outputText value="#{p.detalle} "/>
                            </h:column>
                            <h:column >
                                <f:facet name="header">#{label.field4}</f:facet> 
                                <h:outputText value="#{p.archivo} "/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{label.field3}</f:facet> 
                                <h:outputLink class="mostrar" value="#{path.requestPathView}#{p.archivo}"> 
                                    <h:outputText value="#{label.button5}"/>  
                                </h:outputLink>     
                            </h:column>
                        </h:dataTable>
                    </h:panelGroup>
                </h:form>
            </h:body>
        </ui:define>
        <!--Segemento donde se define un texto de ayuda para que el usuario pueda utilizar el formulario del contenido-->
        <ui:define name="slideHelper">
            <h3>#{help.title1}</h3>
            #{help.detail1a}
            <p>
                #{help.title2}
                <ul>
                    <li>#{help.detail2a}</li>
                    <li>#{help.detail2b}</li>
                </ul>
            </p>
            <p>
                #{help.title3}
                <ul>
                    <li>#{help.detail3a}</li>
                </ul>
            </p>
            <p>
                #{help.title4}
                <ul>
                    <li>#{help.detail4a}</li>
                    <li>#{help.detail4b}</li>
                </ul>
            </p>  

        </ui:define>
    </ui:composition>




</html>

